package com.hui.web.servlet.roomServlet;

import com.hui.bean.RoomBean;
import com.hui.service.IRoomService;
import com.hui.service.impl.RoomServiceImpl;
import com.hui.util.MyBeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "RoomAddExecuteServlet", urlPatterns = "/room/add/execute")
public class RoomAddExecuteServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//
//        String roomAddress = request.getParameter("roomAddress");
//
//        String buildingType = request.getParameter("buildingType");
//
//        String capNum = request.getParameter("capNum");
//
//        String roomType = request.getParameter("roomType");
//
//        String rentPrice = request.getParameter("rentPrice");
//
//        String payType = request.getParameter("payType");
//
//        String roomHost = request.getParameter("roomHost");
//
//        String hostPhone = request.getParameter("hostPhone");
//
//        String roomStatus = request.getParameter("roomStatus");
//
//        String rentDate = request.getParameter("rentDate");
        RoomBean roomBean = new RoomBean();
        MyBeanUtils.populate(roomBean, request.getParameterMap());
        System.out.println(roomBean);

        IRoomService roomService = new RoomServiceImpl();
        roomService.addRoom(roomBean);

        response.sendRedirect("/room/index");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
